﻿#define APP
using System;
using System.Threading;
using System.Collections.Generic;
using System.Windows.Forms;
using _dmis.fee;

namespace _dmis
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //异常处理
            Application.ThreadException +=
               new ThreadExceptionEventHandler(Application_ThreadException);

            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

#if APP
            MainForm mainForm = new MainForm();
            DlgFormFactory.GetController().Attach(mainForm);
            Application.Run(mainForm);
#else
            
            //_dmis.fee.Report dlg = new Report();
            Application.Run(new _dmis.engineering.FeeSelectDlg());
#endif
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is System.Exception)
            {
                HandleException((System.Exception)e.ExceptionObject, "Unhandled Policy");
            }
        }

        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            HandleException(e.Exception, "UI Policy");
        }

        public static void HandleException(Exception ex, string policy)
        {
            Boolean rethrow = false;
            MessageBox.Show(ex.Message, "提示");
        }
    }
}